| Conditions | 1 |
| Paths | 1 |
| Total Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var chai = require('chai'); |
||
| 11 | describe('Create', function() { |
||
| 12 | before( function(done) { |
||
| 13 | Manager.instance.init() |
||
| 14 | .then(function () { |
||
| 15 | Manager.instance._whereKeys = ['title', 'priority', 'abe_meta', 'articles'] |
||
| 16 | Manager.instance.updateList() |
||
| 17 | |||
| 18 | this.fixture = { |
||
| 19 | tag: fse.readFileSync(path.join(__dirname, 'fixtures/templates/article.html'), 'utf8'), |
||
| 20 | jsonArticle: fse.readJsonSync(path.join(__dirname, '/fixtures/files/article-4.json')), |
||
| 21 | jsonHomepage: fse.readJsonSync(path.join(__dirname, '/fixtures/data/homepage-1.json')) |
||
| 22 | } |
||
| 23 | done() |
||
| 24 | |||
| 25 | }.bind(this)) |
||
| 26 | }); |
||
| 27 | |||
| 28 | it('cmsOperations.create()', function(done) { |
||
| 29 | cmsOperations.create('article', '', 'article-2.html', {query: ''}, this.fixture.jsonArticle, false) |
||
| 30 | .then(function(resSave) { |
||
| 31 | var json = path.join(config.root, config.data.url, resSave.abe_meta.latest.abeUrl.replace('.html', '.json')) |
||
| 32 | console.log(json) |
||
|
|
|||
| 33 | var stat = fse.statSync(json) |
||
| 34 | if (stat) { |
||
| 35 | chai.expect(stat).to.not.be.undefined; |
||
| 36 | } |
||
| 37 | fse.removeSync(json) |
||
| 38 | done() |
||
| 39 | }.bind(this)); |
||
| 40 | }); |
||
| 41 | |||
| 42 | it('cmsOperations.duplicate()', function(done) { |
||
| 43 | cmsOperations.duplicate('article-1.html', 'article', '', 'article-2.html', {}, false) |
||
| 44 | .then(function(resSave) { |
||
| 45 | var json = path.join(config.root, config.data.url, resSave.abe_meta.latest.abeUrl.replace('.html', '.json')) |
||
| 46 | var stat = fse.statSync(json) |
||
| 47 | if (stat) { |
||
| 48 | chai.expect(stat).to.not.be.undefined; |
||
| 49 | } |
||
| 50 | fse.removeSync(json) |
||
| 51 | done() |
||
| 52 | }.bind(this)) |
||
| 53 | }); |
||
| 54 | |||
| 55 | it('cmsOperations.duplicate() update', function(done) { |
||
| 56 | cmsOperations.duplicate('article-1.html', 'article', '', 'article-1.html', {}, true) |
||
| 57 | .then(function(resSave) { |
||
| 58 | var json = path.join(config.root, config.data.url, resSave.abe_meta.link.replace('.html', '.json')) |
||
| 59 | var stat = fse.statSync(json) |
||
| 60 | if (stat) { |
||
| 61 | chai.expect(stat).to.not.be.undefined; |
||
| 62 | } |
||
| 63 | done() |
||
| 64 | }.bind(this)) |
||
| 65 | }); |
||
| 66 | }); |
||
| 67 |